﻿Imports extranet.BE
Imports extranet.DA

Public Class BCProva

  Public Shared Function Cadastrar(ByVal objBEProva As BEProva) As Integer
    Dim objDAProva As New DAProva
    Return objDAProva.Cadastra(objBEProva)
  End Function

  Public Shared Sub Atualizar(ByVal objBEProva As BEProva)
    Dim objDAProva As New DAProva
    objDAProva.Atualiza(objBEProva)
  End Sub

  Public Shared Sub RelacionaProvaQuestao(ByVal objBEProva As BEProva)
    Dim objDAProva As New DAProva
    objDAProva.RelacionaProvaQuestao(objBEProva)
  End Sub

  Public Shared Sub MudaOrdemQuestao(ByVal objBEProva As BEProva)
    Dim objDAProva As New DAProva
    objDAProva.MudaOrdemQuestao(objBEProva)
  End Sub

  Public Shared Sub Excluir(ByVal objBEProva As BEProva)
    Dim objDAProva As New DAProva
    objDAProva.Exclui(objBEProva)
  End Sub

  Public Shared Function Selecionar(ByVal intIdProva As Integer) As List(Of BEProva)
    Dim objDAProva As New DAProva()
    Dim objBEProvas As IList(Of BEProva) = Nothing
    If intIdProva > 0 Then
      objBEProvas = objDAProva.Seleciona(New BEProva(intIdProva))
      For Each objBEProva As BEProva In objBEProvas
        objBEProva.Questoes = BCQuestao.Selecionar("", objBEProva.Id, "", "")
      Next
    End If
    Return objBEProvas
  End Function

  Public Shared Function ResumoDaProva(ByVal intIdCandidato As Integer, ByVal intIdProva As Integer) As BEProva
    Dim objDAProva As New DAProva()
    Dim objBEProva As BEProva = Nothing
    If intIdProva > 0 AndAlso intIdCandidato > 0 Then
      objBEProva = objDAProva.ResumoDaProva(intIdCandidato, intIdProva)
      objBEProva.Questoes = BCQuestao.SelecionarRespostasQuestao(intIdCandidato, intIdProva)
    End If
    Return objBEProva
  End Function

  Public Shared Function ResumoDaProva(ByVal strAluno As String, ByVal intIdProva As Integer) As BEProva
    Dim objDAProva As New DAProva()
    Dim objBEProva As BEProva = Nothing
    If intIdProva > 0 AndAlso strAluno.Length() > 0 Then
      objBEProva = objDAProva.ResumoDaProva(strAluno, intIdProva)
      objBEProva.Questoes = BCQuestao.SelecionarRespostasQuestao(strAluno, intIdProva)
    End If
    Return objBEProva
  End Function

  Public Shared Function SelecionarSemQuestoes(ByVal intIdProva As Integer) As List(Of BEProva)
    Dim objDAProva As New DAProva()
    Dim objBEProvas As IList(Of BEProva) = Nothing
    If intIdProva > 0 Then objBEProvas = objDAProva.Seleciona(New BEProva(intIdProva))
    Return objBEProvas
  End Function

  Public Shared Function Selecionar(ByVal strCodigo As String, ByVal strTitulo As String, _
                                    ByVal sortExpression As String, ByVal sortDirection As String) As List(Of BEProva)
    Dim objDAProva As New DAProva
    Dim objBEProva As New BEProva
    objDAProva.objQuery.Sort = New BESort(sortExpression, sortDirection)
    objBEProva.Codigo = strCodigo
    objBEProva.Titulo = strTitulo
    Return objDAProva.Seleciona(objBEProva)
  End Function

  Public Shared Function NumeroQuestoes(ByVal objBEProva As BEProva) As Integer
    Dim DAProva As New DAProva()
    Return DAProva.NumeroQuestoes(objBEProva)
  End Function

End Class